package com.smashit.tacocloud.converter;

import com.smashit.tacocloud.domain.Ingredient;
import com.smashit.tacocloud.repository.IngredientRepository;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

@Component
public class IngredientConverter implements Converter<String, Ingredient> {
    
    private final IngredientRepository ingredientRepository;
    
    public IngredientConverter(IngredientRepository ingredientRepository) {
        this.ingredientRepository = ingredientRepository;
    }

    @Override
    public Ingredient convert(String id) {
        return ingredientRepository.findById(id);
    }
}
